const registerForm = document.getElementById('registerForm');
registerForm.addEventListener('submit', function (e) {
    e.preventDefault();
    const username = document.getElementById('username').value;
    const password = document.getElementById('password').value;
    const email = document.getElementById('email').value;
    const phone = document.getElementById('phone').value;
    fetch('/api/register', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        body: `username=${username}&password=${password}&email=${email}&phone=${phone}`
    })
        .then(response => response.json())
        .then(data => {
            if (data && data.message === "注册成功") {
                alert(data.message);
                // 可以根据需要进行其他成功后的操作，比如跳转到登录页面
            } else {
                alert(data.message);
            }
        });
});